home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-07-24 | 1.6 KB | 62 lines | [TEXT/Moml] |
- (* make_opcodes.sml -- 08Jun96 e *)
-
- (* usually no need: load "BasicIO"; load List; load String; *)
-
- load "FileSys";
-
- open BasicIO;
-
- fun make_opcodes_guts is os =
- let fun delim c = List.exists (fn x => (x = c)) (String.explode " ,;{}\n\t")
- fun enums x =
- let val lin = input_line is
- val toks = String.tokens delim lin
- in
- if toks = []
- then if end_of_stream is then () else enums x (* blank line *)
- else if String.compare (hd toks, "enum") = EQUAL
- then (outputc os "\n"; enums 0) (* new start *)
- else if String.< (hd toks, "A")
- then enums x (* comment *)
- else (
- outputc os "val ";
- outputc os (hd toks);
- outputc os " = ";
- outputc os (makestring x);
- outputc os ";\n";
- enums (x + 1)
- )
- end
- in enums 0
- end
- ;
-
- fun make_opcodes hdr src tgt =
- let val is = open_in src
- in let val os = open_out tgt
- in
- (outputc os hdr;
- make_opcodes_guts is os;
- close_in is;
- close_out os)
- handle x => (close_out os; FileSys.remove tgt; raise x)
- end
- handle x => (close_in is; raise x)
- end
- ;
-
- (*
- val home = "jalaMPW:ml:mosml140:";
-
- load "Date";
- load "Time";
-
- make_opcodes ("(* made by make_opcodes.sml -- "
- ^ (Date.toString (Date.fromTime (Time.now ())))
- ^ " *)\n\n")
- (home ^ "src:!runtime:instruct.h")
- (home ^ "src:compiler:Opcodes.sml**new**");
- *)
-
- (* end *)
-